// packageStore/components/promotion-top/promotion-top.js
const componentBehavior = require('../../../js/common/ComponentBehavior')
const { router } = require('../../../js/router')

Component({
  behaviors: [componentBehavior],
  /**
   * 组件的属性列表
   */
  properties: {
    promoteInfo: {
      type: Object,
      value: {},
    },
    minGoodsCount: {
      type: Array,
      value: [],
    },
    mustBuyGoods: {
      type: Array,
      value: []
    },
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    /**
     * 点击分享按钮
     */
    share() {
      this.triggerEvent('share')
    },
    /**
     * 点击查看必买商品
     */
    toMustBuy() {
      let mustBuyGoods = this.data.mustBuyGoods || []
      let goodsIds = mustBuyGoods.map(item => {
        return item.GoodsId || ''
      })
      goodsIds = goodsIds.join(',')
      router.navigate({
        path: "mustBuyProductList",
        params: {
          goodsIds
        }
      })
    }
  }
})